package com.happycolor.qeuip.util;

import java.util.Properties;

import org.springframework.util.PropertyPlaceholderHelper;
import org.springframework.util.SystemPropertyUtils;

/**
 * 系统常量配置
 * 
 * @author zhangjing_pe
 * 
 */
public class QeuipConfig { 
	/** 系统默认编码 */

	private static Properties props = null;

	/**
	 * 解析property的placeholder工具
	 */
	private static PropertyPlaceholderHelper helper = 
		new PropertyPlaceholderHelper(SystemPropertyUtils.PLACEHOLDER_PREFIX, 
				SystemPropertyUtils.PLACEHOLDER_SUFFIX, SystemPropertyUtils.VALUE_SEPARATOR, false);


	/**
	 * 根据配置的key
	 * @param configKey
	 * @return
	 */
	public static String getConfig(String configKey) {
		if (props == null) {
			return null;
		}
		return getProperty(configKey);
	}
	/**
	 * 获取系统默认帐号的配置
	 * @return
	 */
	public static String getDefaultAdminAccountConf() {
		return props == null ? null : getProperty("system.defaultAdminAccount");
	}

	

	public void setProps(Properties props) {
		QeuipConfig.props = props;
	}
	
	private static String getProperty(String key){
		return helper.replacePlaceholders(props.getProperty(key), props);
	}

}
